import { Router } from 'express';
import { register, login, getProfile, updateProfile, getUsers, createUser, updateUser, deleteUser } from '../controllers/userController';
import { auth, checkRole } from '../middlewares/auth';

const router = Router();

// 认证相关路由
router.post('/register', register);
router.post('/login', login);
router.get('/profile', auth, getProfile);
router.put('/profile', auth, updateProfile);

// 用户管理路由
router.get('/', auth, checkRole(['admin']), getUsers);
router.post('/', auth, checkRole(['admin']), createUser);
router.put('/:id', auth, checkRole(['admin']), updateUser);
router.delete('/:id', auth, checkRole(['admin']), deleteUser);

export default router; 